package biznussoft.fieldservice360.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import biznussoft.fieldservice360.R;
import biznussoft.fieldservice360.model.ContactsModel;



public class ContactMasterAdapter extends BaseAdapter {
	
	ArrayList<ContactsModel> listdata;
	Context mContext;

	public ContactMasterAdapter(Context context, ArrayList<ContactsModel> list) {
		// TODO Auto-generated constructor stub
		this.listdata = list;
		this.mContext = context;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return listdata.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
	
	public class ViewHolder{
		public TextView name;
		public TextView phno;
//		public TextView Email;
//		public TextView title;
//		public ImageView image;
	}

	public View getView(int position, View v, ViewGroup parent) {
		// TODO Auto-generated method stub
		
		ViewHolder holder;
		
		if(v == null){
			
			holder = new ViewHolder();
			LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = inflator.inflate(R.layout.common_details_page, null);
			holder.name  = (TextView) v.findViewById(R.id.text1);
//			holder.title  = (TextView) v.findViewById(R.id.text2);
//			holder.Email = (TextView) v.findViewById(R.id.text3);
			holder.phno = (TextView) v.findViewById(R.id.text2);
//			holder.image = (ImageView) v.findViewById(R.id.imageview);
			
			v.setTag(holder);
		}else{
			holder = (ViewHolder) v.getTag();
		}
		
		ContactsModel bean = listdata.get(position);
			holder.phno.setVisibility(View.VISIBLE);
			
			holder.name.setText(bean.getLastName());
//			holder.title.setText(bean.getTitle());
//			holder.Email.setText(bean.getEmail());
			holder.phno.setText(bean.getPhone());
//			holder.image.setImageResource(R.drawable.contact);
		
		return v;
	}

}
